package com.example.competitionregistration.handle;

import com.example.competitionregistration.common.ErrorCode;
import com.example.competitionregistration.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author QuanJingFang
 * @Description //TODO 异常处理类，捕获可能会出现的异常
 * @Date 2023/7/15 20:24
 **/
@RestControllerAdvice
public class AllExpectionHandle {

    /**
     * @Author QuanJingFang
     * @Description //TODO 捕获异常并进行处理，返回系统错误的结果
     * @Date 2023/7/15 20:35
     * @Param [exception]
     * @return com.example.competitionregistration.entity.Result
     **/
    @ExceptionHandler(Exception.class)
    public Result doExpection(Exception exception){
        exception.printStackTrace();
        return Result.error(ErrorCode.SYSTEM_ERROR.getCode(),ErrorCode.SYSTEM_ERROR.getMsg());
    }
}
